package com.heima.comment.controller;

import com.heima.comment.service.CommentRepayService;
import com.heima.model.common.comment.dtos.CommentRepayDto;
import com.heima.model.common.comment.dtos.CommentRepayLikeDto;
import com.heima.model.common.comment.dtos.CommentRepaySaveDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment_repay")
@Slf4j
public class CommentRepayController {
    @Autowired
    private CommentRepayService commentRepayService;

    /**
     * 保存
     */
    @PostMapping("/save")
    public ResponseResult saveComment(@RequestBody CommentRepaySaveDto commentRepaySaveDto){
        log.info("保存{}",commentRepaySaveDto);
        return commentRepayService.saveComment(commentRepaySaveDto);
    }

    /**
     * 查询评论回复列表
     */
    @PostMapping("/load")
    public ResponseResult loadCommentRepay(@RequestBody CommentRepayDto commentRepayDto){
        log.info("查询评论回复列表{}",commentRepayDto);
        return commentRepayService.loadCommentRepay(commentRepayDto);
    }

    /**
     * 点赞
     */
    @PostMapping("/like")
    public ResponseResult likeCommentRepay(@RequestBody CommentRepayLikeDto commentRepayLikeDto){
        log.info("点赞接收参数{}",commentRepayLikeDto);
        return commentRepayService.likeCommentRepay(commentRepayLikeDto);

    }
}
